package cn.luischen.service.user.impl;

import static org.junit.Assert.assertEquals;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import com.alibaba.fastjson.JSON;

import cn.luischen.utils.TaleUtils;

/**
* The class <code>UserServiceImplTest</code> contains tests for the class <code>{@link UserServiceImpl}</code>.
* Copyright (c) 2020
* 
* @generatedBy UnitSpirit at 2020-07-08 12:56:33
* @version 1.0.0
*/

@RunWith(PowerMockRunner.class)
public class UserServiceImpl_WGTest2 {

	@InjectMocks
	cn.luischen.service.user.impl.UserServiceImpl unitspirit_fixture;
	@Mock
	cn.luischen.dao.UserDao mock_UserDao;

	/**
	* 测试方法初始化.
	* 
	* @throws Exception 
	*         if the initialization fails for some reason 
	*  
	* @generatedBy UnitSpirit at 2020-07-08 12:56:33
	*/
	@org.junit.Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
		try {
			MockitoAnnotations.initMocks(this);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}


  /**
  * @date 0707_204348_276_8
  * @method:login
  * @category auto generate by UnitSpirit  
  */
 //[{"afterReturning":true,"caseDate":"0707_204348_276_8","classModifiers":1,"className":"cn.luischen.service.user.impl.UserServiceImpl","deep":0,"genericParameterTypes":["java.lang.String","java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"login","params":["admin","123456"],"returnObj":"{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1234\",\"uid\":1,\"username\":\"admin\"}","returnType":"cn.luischen.model.UserDomain","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setGroupName","params":["visitor"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"setLogged","params":[0],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"setActivated","params":[0],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"setCreated","params":[1490756162],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setScreenName","params":["admin1234"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setEmail","params":["1034683568@qq.com"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setPassword","params":["a66abb5684c45962d887564f08346e8d"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":1,"methodName":"setUsername","params":["admin"],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":["java.lang.Integer"],"interface":false,"methodModifiers":1,"methodName":"setUid","params":[1],"returnObj":"","returnType":"void","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.model.UserDomain","deep":1,"genericParameterTypes":[],"interface":false,"methodModifiers":1,"methodName":"<init>","params":[],"returnObj":"{\"password\":\"111111\"}","returnType":"cn.luischen.model.UserDomain","throw":false},{"afterReturning":true,"caseDate":"0707_204348_276","classModifiers":1,"className":"cn.luischen.utils.TaleUtils","deep":1,"genericParameterTypes":["java.lang.String"],"interface":false,"methodModifiers":9,"methodName":"MD5encode","params":["admin123456"],"returnObj":"\"a66abb5684c45962d887564f08346e8d\"","returnType":"java.lang.String","throw":false}]
  
  @Test
  
	@PrepareForTest({ cn.luischen.utils.TaleUtils.class })
  
  public void test_login_0707_204348_276_8() throws Throwable {
      cn.luischen.model.UserDomain mock_sub_caller_UserDomain1 = PowerMockito.mock(cn.luischen.model.UserDomain.class);
    //getParamInitForCommon
    java.lang.String Stringmock1_0 =  "visitor";
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setGroupName",Mockito.any(String.class));
    //getParamInitForCommon
    java.lang.Integer Integermock2_0 = 0;
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setLogged",Mockito.any(Integer.class));
    //getParamInitForCommon
    java.lang.Integer Integermock3_0 = 0;
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setActivated",Mockito.any(Integer.class));
    //getParamInitForCommon
    java.lang.Integer Integermock4_0 = 1490756162;
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setCreated",Mockito.any(Integer.class));
    //getParamInitForCommon
    java.lang.String Stringmock5_0 =  "admin1234";
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setScreenName",Mockito.any(String.class));
    //getParamInitForCommon
    java.lang.String Stringmock6_0 =  "1034683568@qq.com";
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setEmail",Mockito.any(String.class));
    //getParamInitForCommon
    java.lang.String Stringmock7_0 =  "a66abb5684c45962d887564f08346e8d";
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setPassword",Mockito.any(String.class));
    //getParamInitForCommon
    java.lang.String Stringmock8_0 =  "admin";
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setUsername",Mockito.any(String.class));
    //getParamInitForCommon
    java.lang.Integer Integermock9_0 = 1;
    PowerMockito.doNothing().when(mock_sub_caller_UserDomain1,"setUid",Mockito.any(Integer.class));
    //generateForSubCallerStatic
    PowerMockito.mockStatic(cn.luischen.utils.TaleUtils.class);
    java.lang.String mock_result_String11 =  JSON.parseObject("\"a66abb5684c45962d887564f08346e8d\"",java.lang.String.class);
    PowerMockito.when(TaleUtils.MD5encode(Mockito.any(String.class))).thenReturn( mock_result_String11);
    //getParamInitForCommon
    java.lang.String String_p_0 =  "admin";
    //getParamInitForCommon
	java.lang.String String_p_1 = "123456";
    cn.luischen.model.UserDomain unitspirit_result=  unitspirit_fixture.login(String_p_0,String_p_1);
    System.out.println("unitspirit_check:test_login_0707_204348_276_8:" + JSON.toJSONString(unitspirit_result));
    cn.luischen.model.UserDomain result_expected =  JSON.parseObject("{\"activated\":0,\"created\":1490756162,\"email\":\"1034683568@qq.com\",\"groupName\":\"visitor\",\"logged\":0,\"password\":\"a66abb5684c45962d887564f08346e8d\",\"screenName\":\"admin1234\",\"uid\":1,\"username\":\"admin\"}",cn.luischen.model.UserDomain.class);
    assertEquals(JSON.toJSONString(result_expected),JSON.toJSONString(unitspirit_result));
  }

}